import React, { useState, useEffect, useMemo } from 'react';
import { Modal, Button, Skeleton, Image, message, Upload, Row, Col, Space, Tag, Tabs } from 'antd'
import { UploadOutlined, LoadingOutlined, CloseOutlined } from '@ant-design/icons';
import type { TabsProps } from 'antd';
import type { UploadChangeParam } from 'antd/es/upload';
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
import { information } from '@/utils/rules';
import Utils from 'fr-util/utils';

import {
  ProFormText,
  ProForm,
  ProFormTextArea,
  ProFormSelect,
  ProFormDependency,
  ProCard,
  CheckCard
} from '@ant-design/pro-components';


import {
  reqPulseCalibrationList,
  reqTongueCalibrationList,
  reqDiagnosisTermList,
  reqDiagnosisTermListByGrade,
  reqSeniorInquiryList,
  reqSeniorInquiryUpdate,
  reqSymptomList,
  reqSymptomListByGrade,
  reqWesternMedicineList,
  reqBaseFormulaList,
  reqBaseFormulaDetailList,
  reqEtiologyCategoryList,
  reqEtiologyList,
  reqEtiologyCategoryListByDiagnosis,
  reqSeniorInquiryPrescriptionMedication,
  reqBaseFormulaDetailGetBaseFormulaHerb,
} from '@/services/firstConsultation';
import WesternMedicineList from './WesternMedicineList'

import BaseFormulaList from './BaseFormulaList'

import styles from '../index.module.less'

const EditModal: React.FC = ({
  isOpen,
  user,
  handleModal,
  type,
}) => {

  const [selectList, setSelectList] = useState([])


  // useEffect(() => {
  //   if (defArr && defArr?.length > 0 && data && data?.length > 0) {
  //     const initList = defArr.map((item: any) => item?.id)
  //     setSelectList(initList)
  //   }
  // }, [defArr, data])



  // async function init(query = {}) {
  //   const errLogName = '西药信息列表'
  //   try {
  //     const res = await reqWesternMedicineList({ ...query })
  //     console.log(`${errLogName}信息 :>> `, res?.data);
  //     if (res?.resultCode == '00000000') {
  //       setData(res?.data)
  //     } else {
  //       message.error(`${errLogName}信息出错！${res?.message}`)
  //     }
  //   } catch (error: any) {
  //     message.error(`${errLogName}信息出错！`, error)
  //     console.log(`${errLogName}信息出错！ :>> `, error);
  //   }
  // }

  // useEffect(() => {
  //   init()
  // }, [])




  // console.log('selectList===== :>> ', selectList);
  const wrapItems: TabsProps['items'] = [
    {
      key: '1',
      label: '西药',
      children: <WesternMedicineList
        user={user}
        handleModal={handleModal}
      />
    }, {
      key: '2',
      label: '汤剂',
      children: <BaseFormulaList user={user} closeModal={handleModal} />,
    }
  ]

  return (
    <Modal
      width={'80vw'}
      title=""
      open={isOpen}
      onCancel={() => handleModal(false)}
      footer={null}
      destroyOnClose={true}
    >
      <div>
        <Tabs
          defaultActiveKey={type}
          items={wrapItems}
        />
      </div>
    </Modal >
  );
};
export default EditModal;

